<template>
	<view class="content">
		<button type="primary" class="entry_button1" @click="goLogin()">点击登录，羽你同行</button>
		<button type="primary" class="entry_button2" @click="goHome()">暂不登录</button>
		<public-module></public-module>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {};
		},
		methods: {
			...mapMutations(['setLoginPopupShow']),
			goLogin() {
				//判断缓存中是否有用户数据（也就是判断有没有登录）
				if (!uni.getStorageSync('encryptedData')) {
					console.log("系统无缓存，请求登录")
					this.setLoginPopupShow(true);
				} else {
					console.log('已授权登录');
					console.log(wx.getStorageSync('sessionID'));
					uni.switchTab({
						url: '/pages/main/home'
					})
				}
			},
			goHome() {
				if (wx.getStorageSync('nickName')) {
					wx.clearStorage();
					getApp().globalData.getsessionID = '';
					getApp().globalData.userId = '';
					getApp().globalData.blogType = 0;
					getApp().globalData.myFansNumber = 0;
					getApp().globalData.myFollowsNumber = 0;
					getApp().globalData.otherFansNumber = 0;
					getApp().globalData.otherFollowNumber = 0;
					getApp().globalData.postDetail = [];
					getApp().globalData.nickName = ''; // 用户昵称
					getApp().globalData.avatarUrl = ''; // 用户头像
					getApp().globalData.loginModal = 0; // 解决登录跳转
					getApp().globalData.chooseTarId = ''; // 选中用户ID
					getApp().globalData.chooseTarName = ''; // 选中用户名字
					getApp().globalData.chooseAvatar = ''; // 选中用户头像	
				}
				uni.switchTab({
					url: '/pages/main/home'
				})
			}
		},
	};
</script>

<style>
	.content {
		background-image: url();
		/* 图片素材permit.png */
		background-size: cover;
		height: 100vh;
		width: 100vw;
		display: flex;
		flex-direction: column;
	}

	.entry_button1 {
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		bottom: 22%;
		background-color: green;
		color: white;
		padding: 5px 15px;
		border: none;
		border-radius: 10px;
		cursor: pointer;
		width: 220px;
		/* 设置按钮宽度 */
		height: 55px;
		/* 设置按钮高度 */
	}

	.entry_button2 {
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		bottom: 11%;
		background-color: green;
		color: white;
		padding: 5px 15px;
		border: none;
		border-radius: 10px;
		cursor: pointer;
		width: 220px;
		/* 设置按钮宽度 */
		height: 55px;
		/* 设置按钮高度 */
	}
</style>